package cn.edu.jmu.oelp.service.impl;

import cn.edu.jmu.oelp.mapper.EntityRelationMapper;
import cn.edu.jmu.oelp.pojo.EntityRelation;
import cn.edu.jmu.oelp.service.EntityRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class EntityRelationImpl implements EntityRelationService {
    @Autowired
    private EntityRelationMapper entityRelationMapper;
    @Override
    public List<EntityRelation> findAll(){
        return entityRelationMapper.findAll();
    }
    @Override
    public EntityRelation findById(long id){
        return entityRelationMapper.findById(id);
    }

    @Override
    public List<EntityRelation> findByStartEntityId(long id){
        return entityRelationMapper.findByStartEntityId(id);
    }

    @Override
    public List<EntityRelation> findByEndEntityId(long id){
        return entityRelationMapper.findByEndEntityId(id);
    }

   @Override
   public List<EntityRelation> findByType(String type){
        return entityRelationMapper.findByType(type);
    }
    @Override
    public List<EntityRelation> findByStartEntityIdAndEndEntityId(long startEntityId, long endEntityId){
        return entityRelationMapper.findByStartEntityIdAndEndEntityId(startEntityId,endEntityId);
    }
    @Override
    public EntityRelation findByStartEntityIdAndEndEntityIdAndType(long startEntityId, long endEntityId, String type){
        return entityRelationMapper.findByStartEntityIdAndEndEntityIdAndType(startEntityId,endEntityId,type);
    }
    @Override
    public int addRelation(EntityRelation entityRelation){
        return entityRelationMapper.addRelation(entityRelation);
    }
    @Override
    public int delRelation(int id){
        return entityRelationMapper.delRelation(id);
    }
    @Override
    public int updateRelation(EntityRelation entityRelation){
        return entityRelationMapper.updateRelation(entityRelation);
    }

}
